from time import*
s1=open("m1_sorted.txt").readlines()
s2=open("m2_reverse.txt").readlines()
s3=open("m3_shuffle.txt").readlines()
h=[]
h2=[]
h3=[]
for i in range(len(s1)):
    h.append(int(s1[i]))
   

a=time()

for i in range(len(h)-1):
    k=0
    for j in range(len(h)-i-1):
        if h[j]>h[j+1]:
            h[j],h[j+1]=h[j+1],h[j]
            k +=1
    if k==0:
        break
b=time()
l=int((b-a)*1000)










for i in range(len(s2)):
    h2.append(int(s2[i]))

a2=time()

for i in range(len(h2)-1):
    k2=0
    for j in range(len(h2)-i-1):
        if h2[j]>h2[j+1]:
            h2[j],h2[j+1]=h2[j+1],h2[j]
            k2 +=1
    if k2==0:
        break
b2=time()
l2=int((b2-a2)*1000)









for i in range(len(s3)):
    h3.append(int(s3[i]))

a3=time()

for i in range(len(h3)-1):
    k3=0
    for j in range(len(h3)-i-1):
        if h3[j]>h3[j+1]:
            h3[j],h3[j+1]=h3[j+1],h3[j]
            k3 +=1
    if k3==0:
        break
b3=time()
l3=int((b3-a3)*1000)








print("m1_sorted" ,l , " milliseconds")
print("m2_reverse",l2 ,"milliseconds")
print("m3_shuffle",l3 ,"milliseconds")
